//
//  ConHomeCell.m
//  Shengzhuli
//
//  Created by FXGuo on 17/3/17.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "ConHomeCell.h"
#import <UIButton+WebCache.h>
#import "AddGoodsModel.h"

@interface ConHomeCell()

@property (weak, nonatomic) IBOutlet UILabel *titleLab;
@property (weak, nonatomic) IBOutlet UIButton *firstBtn;
@property (weak, nonatomic) IBOutlet UIButton *secondBtn;
@property (weak, nonatomic) IBOutlet UIButton *ThirdBtn;

@end

@implementation ConHomeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.firstBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
    self.secondBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
    self.ThirdBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
}
- (IBAction)btnClick:(UIButton *)btn
{
    AddGoodsModel *goodsModel = self.model.typeList[btn.tag];
    if (self.selectBtn) {
        self.selectBtn(goodsModel.productNo);
    }
}

- (void)setModel:(HomeGoodsModel *)model
{
    _model = model;
    self.titleLab.text = model.recommendName;
    AddGoodsModel *goodsModel;
    if (model.typeList.count>0) {
        goodsModel = model.typeList[0];
        [self.firstBtn sd_setImageWithURL:[NSURL URLWithString:goodsModel.thumbnailUrl] forState:UIControlStateNormal placeholderImage:GetImage(@"default_goods_image")];
    }
    if (model.typeList.count>1) {
        goodsModel = model.typeList[1];
        [self.secondBtn sd_setImageWithURL:[NSURL URLWithString:goodsModel.thumbnailUrl] forState:UIControlStateNormal placeholderImage:GetImage(@"default_goods_image")];
    }
    if (model.typeList.count>2) {
        goodsModel = model.typeList[2];
        [self.ThirdBtn sd_setImageWithURL:[NSURL URLWithString:goodsModel.thumbnailUrl] forState:UIControlStateNormal placeholderImage:GetImage(@"default_goods_image")];
    }
}

@end
